<template>
	<view class="">
		
		<!-- <u-tabs :list="list1" @click="click"></u-tabs> -->
		<view class="tab">
			<view class="item" v-for="(item,index) in list1" :key="index" :class="index==Index?'item-active':''" @click="click(index)">
				{{item.name}}
			</view>
		</view>
		
		
		<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
			<view class="px15 dis-flex-column mt10" v-for="(item, index) in pageList" :key="index" @tap="tapDetail(item.id)">
				<!-- <view class="fs14 fw600 ellipsis-1 lh40">{{item.title}}</view>
				<view v-if="current == 2" class="mt10 dis-flex flex-center" :style="{'background-image': item.images ?'url('+item.images+')' : ''}" style="background-size: 100% 100%;width:410rpx;height: 550rpx; border-radius: 20rpx;">
					<u-image v-if="item.type == 1" src="/static/play.png" width="150" height="150"></u-image>
				</view> 
				<view class="mt10 dis-flex flex-center" :style="{'background-image': item.images ?'url('+item.images+')' : ''}" style="background-size: 100% 100%;width: 690rpx;height: 350rpx; border-radius: 20rpx;">
					<u-image  v-if="item.type == 1" src="/static/play.png" width="150" height="150"></u-image>
				</view>-->
				<!-- <image mode="aspectFill"></image> -->
				<view class="dis-flex-column bg-fff py10 px10">
					<u-image :src="$store.state.host + item.image" width="650" height="200" mode="scaleToFill"></u-image>
					<view class="fs16 fw600 ellipsis-1 mt12">{{item.title}}</view>
				</view>
				<!-- <view class="dis-flex flex-align-center flex-between mt10">
					<u-icon name="eye" size="30" color="#999" label-color="#999" :label="item.view" ></u-icon>
					<view class="dis-flex flex-align-center" @click.stop="collect(index,item)">
						<u-icon :name="item.scstatus==2?'heart-fill':'heart'" size="30" :color="item.scstatus==2?'#F7BF75':'#999'" :label-color="item.scstatus==2?'#F7BF75':'#999'" :label="item.scstatus==2?'已收藏':'收藏'" ></u-icon>
					</view>
				</view> -->
			</view>
		</mescroll-body>
	</view>
</template>

<script>
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin],
		data() {
			return {
				pageList: [],
				list1: [{
					name: '全部',
				}, {
					name: '热门',
				}, {
					name: '资讯'
				}, {
					name: '活动'
				}],
				type:0,
				newpage:1,
				Index:0,
			}
		},

		onLoad(option) {
			
		},

		methods: {
			
			
			
			click(index){
				
				this.Index = index
				this.type = index
				this.$http.post(this.$config.UrlNewList, {
					page: this.newpage,
					type:index
				}, {
					log: true,
					header: {
						'content-type': 'application/json'
					}
				}).then((res) => {
					
					let datalist = res?.data?.data || []
					this.pageList = datalist
				
				}).catch((err) => {
					this.mescroll.endErr();
				})
			},

			downCallback() { 
				setTimeout(() => {
					this.mescroll.resetUpScroll();
				}, 1000);
			},

			upCallback(page) {
				
				this.newpage = page.num
				
				this.$http.post(this.$config.UrlNewList, {
					page: page.num,
					type:this.index
				}, {
					log: true,
					header: {
						'content-type': 'application/json'
					}
				}).then((res) => {
					let datalist = res?.data?.data || []
					if (page.num == 1) this.pageList = [];
					this.pageList.push.apply(this.pageList, datalist);
					this.mescroll.endBySize(datalist.length, res?.data?.total);
				}).catch((err) => {
					this.mescroll.endErr();
				})
			},
			
			// 跳转详细
			tapDetail(id) {
				this.$api.openWindow(`/pages/center/newsDetail?id=${id}`);
			}
		}
	}
</script>

<style lang="scss">
	
	/* page{
		background: #fff;
	}
	 */
	.tab{
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 25rpx;
		box-sizing: border-box;
		.item{
			position: relative;
			padding: 25rpx;
			box-sizing: border-box;
		}
		.item-active{
			&::after{
				content: '';
				position: absolute;
				bottom: 0;
				left: 50%;
				transform: translateX(-50%);
				background: #FF5257;
				width: 60%;
				height: 6rpx;
				border-radius: 3rpx;
			}
		}
	}
	.top-search-view {
		position: fixed;
		left: 0;
		background-color: #fff;
		height: 75px;
		z-index: 999;
		width: 100%;
	}

	.product-box-shadow {
		box-shadow: -1rpx -1rpx 20rpx 0rpx rgba(6, 0, 1, 0.08);
	}

	.options-item {
		display: inline-block;
		margin: 20rpx;
		padding: .2rem .5rem;
		border-radius: .1rem;
		background-color: #eee;
		color: #565656 !important
	}

	.popup-button-box {
		position: fixed;
		right: 0;
		bottom: 0;
		width: 560rpx;
		background-color: #ffffff;
		border-top: 1px solid #eee;
		padding-top: 10rpx;
		padding-bottom: 10rpx;
	}
	
	.class-item {
		font-size: 30rpx;
		border-radius: 20rpx;
		padding: 10rpx 20rpx;
		margin-bottom: 20rpx;
		margin-right: 20rpx;
		border: 1rpx solid #ddd;
	}
	.class-activi {
		color: #fff;
		background: linear-gradient(to right,#FF5257,#FC2D38);
	}
</style>
